package demo1;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2023-07-07
 * Time: 10:53
 */
public class Test {
/*    public List<List<Integer>> generate(int numRows){
        List<List<Integer>> ret = new ArrayList<>();
        List<Integer> list = new ArrayList<>();
        list.add(1);
        ret.add(list);
        for (int i = 1; i <numRows ; i++) {
            List<Integer> curRow = new ArrayList<>();
            curRow.add(1);

            List<Integer> preRow = ret.get(i-1);
            for (int j = 1; j < i; j++) {
                int val = preRow.get(j)+preRow.get(j-1);
                curRow.add(val);
            }

            curRow.add(1);
            ret.add(curRow);
        }
        return ret;
    }
    public static void main(String[] args) {

    }*/
    private static final String[] SUITS = {"♥","♠","♣","♦"};

    public static List<Card> buyCard(){
        List<Card> cards = new ArrayList<>();
        for (int i = 0; i < SUITS.length; i++) {
            for (int j = 1; j <= 13 ; j++) {
                Card card = new Card(SUITS[i],j);
                cards.add(card);
            }
        }
        return cards;
    }
    public static void shuffle(List<Card> cards){
        Random random = new Random();
        for (int i = cards.size()-1; i > 0; i--) {
            int j = random.nextInt(i);
            Card tmp = cards.get(i);
            cards.set(i,cards.get(j));
            cards.set(j,tmp);
        }
    }
    public static void main1(String[] args) {
        List<Card> cards = buyCard();
        System.out.println(cards);
        System.out.println("====================");
        shuffle(cards);
        System.out.println(cards);

        List<Card> hand1 = new ArrayList<>();
        List<Card> hand2 = new ArrayList<>();
        List<Card> hand3 = new ArrayList<>();
        List<List<Card>> hand = new ArrayList<>();
        hand.add(hand1);
        hand.add(hand2);
        hand.add(hand3);

        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                Card card = cards.remove(0);
                hand.get(j).add(card);
            }
        }
        System.out.println("第一个人的排:");
        System.out.println(hand1);
        System.out.println("第二个人的排:");
        System.out.println(hand2);
        System.out.println("第三个人的排:");
        System.out.println(hand3);
        System.out.println("牌堆剩下的牌");
        System.out.println(cards);

/*        for (int i = 0; i <cards.size() ; i++) {
            System.out.println(cards.get(i));
        }*/
    }
}
